package edu.ccut.saturn.studio.logic.model.saturn.action;

import org.eclipse.draw2d.geometry.Point;

import edu.ccut.saturn.studio.action.ActionMultiPageEditor;
import edu.ccut.saturn.studio.logic.model.Shape;
import edu.ccut.saturn.studio.logic.model.ShapesDiagram;
import edu.ccut.saturn.studio.logic.model.saturn.SaturnDecisionNode;
import edu.ccut.saturn.studio.logic.model.saturn.logic.SaturnDecisionNodeInLogic;

public class SaturnDecisionNodeInAction extends SaturnDecisionNode {
	private static final long serialVersionUID = 1L;
	
	@Override
	public Shape cloneShape(Point mousePoint, Shape shape) {
		ShapesDiagram diagram = (ShapesDiagram) shape.getParent();
		if (diagram.getEditors() instanceof ActionMultiPageEditor) {
			SaturnDecisionNodeInAction saturnDecisionNode = new SaturnDecisionNodeInAction();
			SaturnDecisionNodeInAction saturn = (SaturnDecisionNodeInAction) shape;
			saturnDecisionNode.setName(saturn.getName());
			saturnDecisionNode.setDescription(saturn.getDescription());
			saturnDecisionNode.setThenid(saturn.getThenid());
			saturnDecisionNode.setFalseId(saturn.getFalseId());
			saturnDecisionNode.setExpression(saturn.getExpression());
			saturnDecisionNode.setLocation(mousePoint);
			saturnDecisionNode.setParameters(saturn.getParameters());
			saturnDecisionNode.setId(saturn.getId());
			saturnDecisionNode.setNextId(saturn.getNextId());
			return saturnDecisionNode;
		} else {
			SaturnDecisionNodeInLogic saturnDecisionNode = new SaturnDecisionNodeInLogic();
			SaturnDecisionNodeInAction saturn = (SaturnDecisionNodeInAction) shape;
			saturnDecisionNode.setName(saturn.getName());
			saturnDecisionNode.setDescription(saturn.getDescription());
			saturnDecisionNode.setThenid(saturn.getThenid());
			saturnDecisionNode.setFalseId(saturn.getFalseId());
			saturnDecisionNode.setExpression(saturn.getExpression());
			saturnDecisionNode.setLocation(mousePoint);
			saturnDecisionNode.setId(saturn.getId());
			saturnDecisionNode.setNextId(saturn.getNextId());
			return saturnDecisionNode;
		}
	}
}
